// 封装请求方法
import {HttpBase} from './config.js'
let shownum = 0;
export const request=(url,data={},method='GET')=>{
  // console.log(data)
  shownum++;
  return new Promise((resolve,reject)=>{
    wx.showLoading({
      title: '数据加载中',
    })
    wx.request({
      url:HttpBase.BaseUrl+url,
      data,
      method,
      dataType: 'json',
      success: (result) => {
        resolve(result.data.message)
      },
      fail: (err) => {
        reject(err)
      },
      complete: ()=>{
        shownum--;
        if(shownum===0){
          wx.hideLoading({
            success: (res) => {},
          })
        }
      }
    });  
  })
}